<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/
  defined('_JEXEC') or die('Retricted Access');
  global $option;
  $items = $this->items;
  $arr_status_invoice = JobBoardConstant::getStatus_Invoice();
  $pagination = $this->pagination;
  $task = JRequest::getVar('task');
  $user_id = JRequest::getVar('userid');
  $cid = JRequest::getVar('userid');
  
//  $n = count($item['s']) + count($item['p']) + count($item['c']);
?>
<form name="adminForm" action="index.php" method="post" enctype="multipart/form-data">
<div style="width:100%;">
    <table width="100%">
		<tr>
			<td width="80%" valign="top">
				<?php echo $this->menu();?>
			</td>
			
				
			
		</tr>
	</table>
	<table width="100%">
		<tr>
			<td width="100%" align="right">
				<?php echo $this->invoice_typeObject; ?>
			</td>
		</tr>
	</table>
	<table class="adminlist" width="100%">
	<thead>
		<tr>
			<th width="5%" align="center">
				<?php echo JText::_( 'NUM' ); ?>
			</th>
			<th width="5%">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $items);?>);" />
			</th>			
			<th class="sectiontableheader" width="15%">            		
    			<?php echo JHTML::_('grid.sort',   JText::_('Invoice ID'), 'invoice_id',@$this->order_dir, @$this->order); ?>
    		</th> 
    		<th class="sectiontableheader" width="20%">            		
    			<?php echo JHTML::_('grid.sort',   JText::_('Date'), 'invoice_date',@$this->order_dir, @$this->order); ?>
    		</th> 
			<th class="sectiontableheader" width="35%">            		
    			<?php echo JHTML::_('grid.sort',   JText::_('Item'), 'posting_plan_id',@$this->order_dir, @$this->order); ?>
    		</th> 
    		<th class="sectiontableheader" width="10%">            		
    			<?php echo JHTML::_('grid.sort',   JText::_('Product Type'), 'status',@$this->order_dir, @$this->order); ?>
    		</th> 
			<th class="sectiontableheader" width="10%">            		
    			<?php echo JHTML::_('grid.sort',   JText::_('Status'), 'status',@$this->order_dir, @$this->order); ?>
    		</th> 
			<th class="sectiontableheader" width="10%">            		
    			<?php echo JHTML::_('grid.sort',   JText::_('Amount'), 'amount',@$this->order_dir, @$this->order); ?>
    		</th> 	
    	</tr>	
    </thead>
	<tfoot>
	<tr>
		<td colspan="13">
			<?php //echo $pagination->getListFooter(); ?>
		</td>
	</tr>
	</tfoot>    
    <tbody>
    <?php
    $count = 0;
   	foreach ($items as $sub_items)
   	{
   		
        for($i = 0, $n = count($sub_items); $i < $n; $i++)
        {
        	$count++;
        	$item = $sub_items[$i];
        	$checked 	= JHTML::_('grid.id',   $i, $item->id );
       ?>
       		<tr class="row<?php echo $i%2; ?>">
       			<td width="5%" align="center">
       				<?php echo $count; ?>
       			</td>
       			<td width="5%" align="center">
       				<?php echo $checked; ?>
       			</td>
       			<td width="15%" align="center">
       			<?php
       				switch (strtolower($item->product_type))
       				{
       					case 's':
       						$jaview = 'jasubscriptions_invoice';
       						break;
       					case 'c':
       						$jaview = 'jacredits_invoice';
       						break;
       					case 'p':
       						$jaview = 'japostingplans_invoice';
       						break;
       				}
       				echo "<a href='index.php?option=$option&view=$jaview&layout=form&task=$task&userid=$user_id&cid[]=$item->id' />";
       				echo $item->display_invoice_id; 
       				echo "</a>";
       			?>
       			</td>
       			<td width="20%" align="center">
       			<?php echo $item->invoice_date; ?>
       			</td>
       			<td width="35%" align="center">
       				<?php echo $item->title; ?>
       			</td>
       			<td>
       				<?php
       					switch ($item->product_type)
       					{
       						case 'P':
       							echo 'Posting Plan';
       							break;
       						case 'C':
       							echo 'Credit';
       							break;
       						case 'S':
       							echo 'Subscription';
       							break;
       					}
       				?>
       			</td>
       			<td width="10%" align="center">
       				<?php echo $arr_status_invoice[$item->status]; ?>
       			</td>
       			<td width="10%" align="center">
       				<?php echo $item->amount; ?>
       			</td>
       		</tr>
       	<?php
        }
   	}
        ?>    
    </tbody>			
	</table>	
</div>	
	<input type="hidden" name="cid" value="<?php echo $cid; ?>" />
	<input type="hidden" name="id" value="<?php echo $item->id; ?>" />
	<input type="hidden" name="user_id" value="<?php echo $cid; ?>" />
	<input type="hidden" name="userid" value="<?php echo $user_id; ?>" />
	<input type="hidden" name="option" value="<?php echo $option; ?>" />
	<input type="hidden" name="boxchecked" value="0" />
	<input type="hidden" name="view" value="jaemployers" />
	<input type="hidden" name="task" value="invoices" />
	

 </form>